<template>
	<view>
		<u-picker 
			v-model="selectedValue" 
			range-key="name" 
			:default-selector="[0]"
			:range="dataList" 
			mode="selector" 
			@confirm="confirm">
		</u-picker>
	</view>
</template>

<script>
	// import {
	// 	mapState
	// } from 'vuex';
	export default {
		props: {
			value: {
				type: Boolean,
				default: false
			}
		},
		data() {
			return {
				dataList: [],
				selectedValue: this.value // 使用本地 data 属性来保存选中的值
			}
		},
		computed: {
			// ...mapState({
			// 	franchiseId: state => state.franchiseId
			// })
		},
		watch:{
			value(val){
				console.log('value',val)
				this.selectedValue = val
			},
			selectedValue(val){
				console.log('selectedValue',val)
				if(!val){
					this.$emit('close',false)
				}
			}
		},
		mounted() {
			this.getDataList()
		},
		methods: {
			getDataList(){
				this.$u.post('/Franchise/List',{
					"pageIndex": 1,
					"pageSize": 999
				}).then((res) => {
					this.dataList = res.rows;
				}).catch((err) => {
					
				})
			},
			confirm(index){
				this.$emit('confirm',this.dataList[index])
			}
		}
	}
</script>

<style>

</style>
